using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       GameSyncSender.cs
*@brief      send message GameSync
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/3/16
*/

//send message GameSync
public class msgGameSync
{
    public const int MessageId = (int)NetMessageTypes.MessageType.GameSync;
    //TODO
	public int SessionId = NetLib.INVALID_SESSION;
	public int GateCode = GlobalDef.INVALID_GATE_CODE;
	public gamesync.GameSyncMain MainMsg = new gamesync.GameSyncMain();
	/// <summary>
	/// Initializes a new instance of the <see cref="msgGameSync"/> class.
	/// </summary>
	/// <param name='session_id'>
	/// Session_id.
	/// </param>
	/// <param name='gate_code'>
	/// Gate_code.
	/// </param>
	/// <param name='sub_id'>
	/// Sub_id.
	/// </param>
	/// <param name='buffer'>
	/// Buffer.
	/// </param>
	public msgGameSync(int session_id, int gate_code, int sub_id, byte[] buffer)
	{
		SessionId = session_id;
		GateCode = gate_code;
		MainMsg.SubId = sub_id;
		MainMsg.SubBuffer = buffer;
	}
}

//handle message
public partial class gwMessagePort
{
    /// <summary>
    /// handle message
    /// </summary>
    /// <param name="msg">message wrapper of GameSync</param>
    public static void ProcessMessage(msgGameSync msg)
    {
        //TODO
		msgGameSyncTransfer trans = new msgGameSyncTransfer(msg.SessionId, msg.GateCode, ProtoNet<gamesync.GameSyncMain>.IntoBytes(msg.MainMsg));
		gwMessagePort.ProcessMessage(trans);
    }
}
